
<template>
  <el-container>
    <el-header>
      <span> 
        <img src="../Home/微信图片_20210407225154.jpg" alt="">
        后台管理系统 </span>
      <button @click="loginOut">退出</button>
    </el-header>
    <el-container>
      <el-aside :width="isCollapse ? '65px' : '150px'">
        <div class="aaa" @click="isCollapse = !isCollapse">|||</div>
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#4399ff"
          :unique-opened="true"
          :router="true"
          :collapse="isCollapse"
          :collapse-transition="true"
        >
          <el-submenu
            :index="item.id + ''"
            v-for="item in menus"
            :key="item.id"
          >
            <template slot="title">
              <i class="el-icon-thumb"></i>
              <span>{{ item.authName }}</span>
            </template>
            <!--里面的 -->
            <el-menu-item-group>
              <el-menu-item
                :index="item2.path"
                v-for="item2 in item.children"
                :key="item2.id"
              >
                <span>{{ item2.authName }}</span>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template> 
<script>
import { userApi } from "@/http/api";

export default {
  data() {
    return {
      menus: [],
      isCollapse: false,
    };
  },
  created() {
    this.getuser();
  },
  methods: {
    loginOut() {
      sessionStorage.removeItem("token");
      this.$router.replace("login");
    },
    async getuser() {
      const res = await userApi();
      console.log(res);
      this.menus = res;
    },
  },
  components: {},
};
</script>

<style lang='scss' scoped>
.home {
  height: 100%;
}
img{
width: 50px
;
height: 50px;
border-radius: 50%;
vertical-align: middle;
}
.el-container {
  height: 639px;
}
.el-header {
  background-color: #525a62;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  // text-align: center;
  line-height: 60px;
  button {
    float: right;
    // line-height: 60px;
    margin-top: 15px;
  }
}
.el-menu {
  width: 160px;
}
.el-aside {
  height: 100%;
  background-color: #525a62;
  color: #fff;
  // text-align: center;
  // line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
    // text-align: center;
    // line-height: 160px;
}
.el-submenu .el-submenu {
  min-width: 20px !important;
}
.aaa {
  text-align: center;
  margin: 5px 0;
  cursor: pointer;
}
</style>
